package zhu.yu.api.static0;

public class StaticFieldStudent {
    private int id;
    private String name;  // 姓名
    private int age;  // 年龄
    static String room;  // 所在教室
    private static int idCounter = 0;  // 学号计数器，每当new一个新对象，都让它加一

    // 构造方法与类同名
    public StaticFieldStudent() {
        this.id = ++idCounter;
    }


    public StaticFieldStudent(String name, int age) {
        this.name = name;
        this.age = age;
        this.id = ++idCounter;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }
}
